package cn.xyfmzmy.chain.validation;


public class MaxValidateHandler implements ValidateHandler{

    private final int max;

    public MaxValidateHandler(int max) {
        this.max = max;
    }

    @Override
    public void validate(Object value, ValidateContext validateContext) {
        if(value instanceof Integer intValue){
            if(intValue > max){
                validateContext.appendError("你的值是" + intValue + "不能大于" + max);
            }
        }
        // 控制责任链往下执行，
        validateContext.doNext(value);
    }
}
